const { contextBridge, ipcRenderer } = require('electron')

ipcRenderer.on('ipcmainHandlerKeys', (_event, ipcmainHandlers) => {
    const electronAPIContent = {};
    ipcmainHandlers.forEach(ipcmainHandlerKey => {
        electronAPIContent[ipcmainHandlerKey] = function () {
            return ipcRenderer.invoke(ipcmainHandlerKey, ...arguments);
        }
    });
    electronAPIContent.process = process;
    electronAPIContent.onEnterFullScreen=(callback) => ipcRenderer.on('enter-full-screen', (_event, value) => callback(value));
    electronAPIContent.onProcessMsg = (callback) => ipcRenderer.on('processMsg', (_event, value) => callback(value));
    contextBridge.exposeInMainWorld('$electron', electronAPIContent);
})